package com.itheima.service.impl;

import com.itheima.dao.BookDao;
import com.itheima.domain.Book;
import com.itheima.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 陆小根
 * date: 2022/05/04
 * Description:
 */
@Service
public class BookServiceImpl implements BookService {

  private final BookDao bookDao;

  @Autowired
  public BookServiceImpl(BookDao bookDao) {
    this.bookDao = bookDao;
  }

  @Override
  public boolean save(Book book) {
    return bookDao.save(book) > 0;
  }

  @Override
  public boolean update(Book book) {
    return bookDao.update(book) > 0;
  }


  @Override
  public boolean delete(Integer id) {
    return bookDao.delete(id) > 0;
  }

  @Override
  public Book getById(Integer id) {
    return bookDao.getById(id);
  }

  @Override
  public List<Book> getAll() {
    return bookDao.getAll();
  }
}
